package com.greatwideweb.runhelper.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHelper extends SQLiteOpenHelper {

  private static final String DATABASE_NAME = "runhelper";
  private static final int DATABASE_VERSION = 1;
  private static final String CREATE_RUN_DATA_TABLE = 
      " create table run_data "+
      " ( "+
      " run_data_id integer not null primary key,  "+
      " distance integer not null, "+
      " distance_part integer,  "+
      " run_time_min integer not null, "+
      " run_time_sec integer not null, "+
      " run_date_dd integer not null, "+
      " run_date_mm integer not null, "+
      " run_date_yyyy integer not null, "+
      " updated_date_dd integer not null, "+
      " updated_date_mm integer not null, "+
      " updated_date_yyyy integer not null, "+
      " comments text"+
      " ); ";

  public DatabaseHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    // TODO Auto-generated constructor stub
  }

  @Override
  public void onCreate(SQLiteDatabase db) {
    // TODO Auto-generated method stub
    db.execSQL(CREATE_RUN_DATA_TABLE);
  }

  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    // TODO Auto-generated method stub
    db.execSQL(CREATE_RUN_DATA_TABLE);
    onCreate(db);

  }

}
